package com.five.welcome.dao;


import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.five.welcome.entity.Orders;
import com.five.welcome.entity.statistic.PayStatusCount;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

/**
 * <p>
 * Mapper 接口
 * </p>
 *
 * @author ywt
 * @since 2024-07-12
 */
@Mapper
public interface OrdersMapper extends BaseMapper<Orders> {
    @Update("update orders set pay_no=#{payNo},pay_time=#{payTime},pay_status=#{payStatus} " +
            "where order_id=#{orderId}")
    void updateByOrderId(Orders orders);

    @Select("SELECT (SELECT COUNT(*) FROM orders WHERE pay_status = '待支付') " +
            "AS un_paid_count,(SELECT COUNT(*) FROM orders WHERE pay_status = '已支付') " +
            "AS paid_count")
    List<PayStatusCount> PayStatusCount();
}
